package com.aaa.service.impl;

import com.aaa.dao.F_YuanGongDao;
import com.aaa.service.F_YuanGongService;
import com.aaa.util.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class F_YuanGongServiceimpl implements F_YuanGongService {
    @Autowired
    F_YuanGongDao dao;

    @Override
    public List<Map> selectList(Map map) {
        return dao.selectList(map);
    }

    @Override
    public Integer getCount(Map map) {
        return dao.getCount(map);
    }

    @Override
    public int delEmp(Integer id) {
        return dao.delEmp(id);
    }

    @Override
    public int add(Map map) {

      //  System.out.println(x);
        //没有加密 加密
        String s = (String) map.get("password");
        if (s.length()<10){
            MD5 md5=new MD5();
            String password=md5.MD5(s);
            map.put("password1",password);
        }else{ map.put("password1",s);}

        //根据name获取文明办id
        String s2 = (String) map.get("manage");
        //System.out.println(password);
        int manage2=dao.getManage(s2);
        //  System.out.println(manage2);
        map.put("manage2",manage2);
        //根据name获取文明办rid
        int x=  dao.getid(map);
        map.put("x",x);
        return dao.add(map);
    }

    @Override
    public int update(Map map) {
        String s = (String) map.get("password");
        if (s.length()<10){
           // System.out.println(111);
            MD5 md5=new MD5();
            String password=md5.MD5(s);
           // System.out.println(password);
            map.put("password1",password);
            //System.out.println(map);
        }else{ map.put("password1",s);}

        String s2 = (String) map.get("manage");
        //System.out.println(password);
        int manage2=dao.getManage(s2);
        //  System.out.println(manage2);
        map.put("manage2",manage2);

        int x=  dao.getid(map);
        //System.out.println(x);
        map.put("x",x);
       // System.out.println(map);
        return dao.update(map);
    }

    @Override
    public List<Map> getRole() {
        return dao.getRole();
    }

    @Override
    public List<Map> getShi() {
        return dao.getShi();
    }

    @Override
    public int getManage(String s2) {
        return dao.getManage(s2);
    }
}
